/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.service.payment;

import java.util.List;
import java.util.Set;

import net.martinimix.domain.order.Order;
import net.martinimix.domain.order.OrderHeader;
import net.martinimix.domain.payment.PaymentMethod;
import net.martinimix.service.payment.handler.PaymentHandler;
import net.martinimix.service.payment.handler.PaymentHandlerNotFoundException;

/**
 * Provides an order payment service capable of handling orders
 * being paid for with multiple payment methods.
 * 
 * @author Scott Rossillo
 *
 */
public interface MultiPaymentService extends PaymentService {
	
	/**
	 * Authorizes the payments in the given payment method list.
	 * 
	 * @param paymentMethods a list of <code>PaymentMethod</code>s to authorize
	 * @param order the <code>Order</code> for which to authorized the
	 * given <code>Payments</code>
	 * 
	 */
	public void authorizePayments(List paymentMethods, Order order);
	
	/**
	 * Creates payments for the given order and payment methods.
	 * 
	 * @param orderHeader the <code>OrderHeader</code> for the order for
	 * which <code>Payment</code>s should be created
	 * 
	 * @param paymentMethods the <code>PaymentMethod</code>s from which to generate
	 * an <code>List</code> of order <code>Payment</code>s
	 * 
	 * @return a list of <code>Payment</code>s for the given <code>orderHeader</code>
	 * from the given <code>paymentMethods</code>
	 */
	public List createPayments(List paymentMethods, OrderHeader orderHeader);
	
	/**
	 * Returns the handler for the given payment method.
	 * 
	 * @param paymentMethod the <code>PaymentMethod</code> whose
	 * payment handler should be returned
	 * 
	 * @return the <code>PaymentHandler</code> for the given
	 * <code>paymentMethod</code>
	 * 
	 * @throws PaymentHandlerNotFoundException if no handler has
	 * been registered for the given <code>paymentMethod</code>
	 * 
	 * @see #setPaymentHandlers(Set)
	 */
	public PaymentHandler findPaymentHandler(PaymentMethod paymentMethod);

}
